package lxh.com.union.logic_business.ui.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import lxh.com.union.R;
import lxh.com.union.config.SinlliaConfig;
import lxh.com.union.frame.mvp.FrameMvpActivity;
import lxh.com.union.logic_business.model.bean.LoginBean;
import lxh.com.union.logic_business.present.LoginPresent;
import lxh.com.union.logic_business.ui.customview.CustomToolBar;
import lxh.com.union.logic_business.ui.mvpview.ILoginView;
import lxh.com.union.logic_business.util.SharePrefUtils;
import lxh.com.union.logic_business.util.ToastUtils;

/**
 * Created by Administrator on 2017/12/4.
 */

public class LoginActivity extends FrameMvpActivity<LoginPresent> implements ILoginView {
    @BindView(R.id.topbar)
    CustomToolBar mTopBar;
    @BindView(R.id.et_phone)
    EditText mEtPhone;
    @BindView(R.id.et_pwd)
    EditText mEtPwd;
    @BindView(R.id.btn_login)
    Button mBtnLogin;
    @BindView(R.id.tv_register)
    TextView mTvRegister;
    @BindView(R.id.tv_findback_pwd)
    TextView mTvFindbackPwd;

    @Override
    protected LoginPresent createPresent() {
        return new LoginPresent();
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_login;
    }

    @OnClick({R.id.iv_back, R.id.btn_login, R.id.tv_register, R.id.tv_findback_pwd})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.btn_login:
                String user=mEtPhone.getText().toString();
                String pwd=mEtPwd.getText().toString();
                mPresent.login(user,pwd);
                break;
            case R.id.tv_register:
                break;
            case R.id.tv_findback_pwd:
                break;
        }
    }


    @Override
    public void login(LoginBean bean) {
        ToastUtils.showLong("登录成功");
        SharePrefUtils.putString(SinlliaConfig.IIDD,bean.getData().getUser_data().getIidd());
        SharePrefUtils.putString(SinlliaConfig.TOKEN,bean.getData().getSEAYO_AUTH());
        finish();
    }

}
